<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>人事合同</title>
<link href="<c:url value='/insdep/reset.min.css' />" rel="stylesheet" type="text/css">
<link href="<c:url value='/insdep/easyui_full.css'/>" rel="stylesheet" type="text/css">
<link href="<c:url value='/insdep/icon.css'/>" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<c:url value='/insdep/jquery-1.11.3.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/insdep/jquery.easyui-1.5.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/insdep/insdep-extend.min.js'/>"></script>

</head>
<body>
<script type="text/javascript">
function fornatter_type(value, row, index){
	return{
		"fixtimecontract": "固定期限劳动合同",
		"nofixtimecontract":"无固定期限劳动合同",
		"dispatchcontract":"劳务派遣合同",
		"nodaycontract":"非全日制用工合同"
	}[value];
}
function note_bianji(val,row,index){
if(row.contractState=="有效"){
	var edit1="";
	var Relieve="";
	edit1= '<a class="easyui-linkbutton button-teal iconfont icon-hetongqicao" style="color:white;padding-left:9%;font-size:14px;padding-right:9%;margin-right:5%" onclick="edit1('+index+')">编辑</a>';
	Relieve= '<a class="easyui-linkbutton button-blue iconfont icon-info" style="color:white;padding-left:9%;padding-right:9%;font-size:14px;margin-right:5%" onclick="Relieve('+index+')">解除</a>';
	return edit1+Relieve;
	}
	
}

$(function(){
	//按条件查询用户
	 $("#queryer").linkbutton({onClick:function(){ 
		 $('#Contract_search_from').form('submit', {   
			 	onSubmit: function(param){  
			 		param.page = '1';    
			        param.rows = '5';
			    }  ,
			    success:function(data){    //表单查询数据刷新DataGrid
			    	var resultData = $.parseJSON(data);  
			    	$('#Contract_table').datagrid('loadData', resultData); 
			    }    
			}); 
	 }});
	
	 $("#reset_con").linkbutton({
			onClick : function() {
				$("#Contract_search_from").form('reset');
			}
		})
	 
})
</script>
<script type="text/javascript">
		$(function() {
			 /* $(".ru").linkbutton({onClick:function(){
				var center = $("body").layout("panel", "center");
				var url = $(this).attr("id");
				center.panel("refresh",url);
			}}) */
			
			$(".ru").linkbutton({
				onClick : function() {
					var title = $(this).text();
					var url = $(this).attr("id");
					//判断该面板是否已打开
					if($("#tt").tabs("exists", title)){
						//已存在则激活
						$("#tt").tabs("select", title);
					}else{
						//不存在
						var config = {
								title: title,
								href: url,
								closable: true
							}
						$("#tt").tabs("add", config);
					}
				}
			}); 
		})
	</script>
<script type="text/javascript">
 $(function() {
	$("#Contract_table").datagrid({onBeforeLoad:function(parm){
		parm.empName=$("#empName").val();
		parm.contractType=$("#contractType").val();
		parm.contractState=$("#contractState").val();
	}})
})
</script>
<script type="text/javascript">
/**
 *编辑事件
 */
function edit1(index){
	$("#ht_xgwin").window({
			  width: 900,
	          height: 600,
	          title: '修改员工档案信息窗口',
	          iconCls: 'icon-update',
	          modal: true,//表示模式窗口
	          maximizable:false,
	          minimizable:false,
	          collapsible:false,
	          draggable: false ,
			  href:'editContract',//请求远程数据
			});
	$('#Contract_table').datagrid('selectRow',index);
 	var row = $('#Contract_table').datagrid('getSelected');
 	alert(row.contractId);
 	var contractId = row.contractId;
	 $.post("editContractInfo", {contractId:contractId} ,function(info){
		 $('#add_contract_form').form('load',info);
     });
	    alert(row);
	
}

function Relieve(index){
	$('#Contract_table').datagrid('selectRow',index);
 	var row = $('#Contract_table').datagrid('getSelected');
 	$.messager.confirm('提示', '您确认要解除该员工的合同吗？', function(r){
		if (r){
		    // 确认;
			$.post("RelieveContract",{contractId:row.contractId}, 
			        function(data){
					//*刷新数据
					if(data){
						$('#Contract_table').datagrid('reload');
						//提示信息
						$.messager.show({
							title:'提示',
							msg:'解除合同成功！', 
						    timeout:1000,  
							showType:'show',
							style:{
					            right:'',  
					            bottom:'' 
							}
						});
					}else{
						//提示信息
						$.messager.show({
							title:'提示',
							msg:'解除合同失败！', 
						    timeout:1000,  
							showType:'show',
							style:{
					            right:'',  
					            bottom:'' 
							}
						});
					}
						
			});
		}
	});
    
}
</script>





<div class="easyui-layout theme-layout" data-options="fit:true">
    <div class="theme-header-layout" style="height:130px;border: 0px solid red" data-options="region:'north'">
    	<div style="margin-left: 5%;width:80%;margin-right:5%;margin-top:20px;border: 0px solid green">
        <form action="ContractInfo" id="Contract_search_from" class="searcher-form" method="post">
    		<input id="empName" name="empName" class="easyui-textbox"  style="width: 30%;"  labelAlign="right" label="姓名：" labelWidth="150px"> 
			<select id="contractType" name="contractType" id="" class="easyui-combobox" style="width: 35%;" labelAlign="right" label="合同类型：" editable="false" labelWidth="150px">
				<option value="">---请选择---</option>
				<option value="fixtimecontract">固定期限劳动合同</option>
				<option value="nofixtimecontract">无固定期限劳动合同</option>
				<option value="dispatchcontract">劳务派遣合同</option>
				<option value="nodaycontract">非全日制用工合同</option>
			</select>
			<select id="contractState" name="contractState" id="" class="easyui-combobox" style="width: 30%;" labelAlign="right" label="合同状态：" editable="false" labelWidth="150px">
				<option value="">---请选择---</option>
				<option value="有效">有效</option>
				<option value="解除">解除</option>
				<option value="解除">过期</option>
			</select>
			<div style="margin-left:21%;margin-top:30px;border: 0px solid red">
			<a id="queryer"  class="easyui-linkbutton button-line-blue" 
			style="width: 14%;height: 30px;"><i class="iconfont icon-roundcheck"></i>查询</a>
			<a id="reset_con"  class="easyui-linkbutton button-line-blue" 
			style="width: 14%;height: 30px;margin-left: 10%"><i class="iconfont icon-refresh"></i>重置</a>
			<a id="Unsigned"  class="easyui-linkbutton button-line-blue ru" 
			style="width: 14%;height: 30px;margin-left: 10%"><i class="iconfont icon-friendadd"></i>未签人员</a>
			<a id="RenewContract"  class="easyui-linkbutton button-line-blue ru" 
			style="width: 14%;height: 30px;margin-left: 10%"><i class="iconfont icon-friendaddfill"></i>续签人员</a>
			<!-- <a id="increase"  class="easyui-linkbutton button-line-orange button-line-unbackground add_btn" 
			style="width: 10%;height: 30px;">查询</a> -->
    		</div>
    	</form>
    	</div>
    </div>
    <div class="theme-center-layout" style="border: 0px solid red" data-options="region:'center',title:'合同信息表'">
        <!-- <div style="margin-left: 12%;margin-right:5%;margin-top:20px;border: 0px solid red"> -->
        <!--  class="table table-striped" -->
        <table id="Contract_table" style="width:100%;height: 100%" class="easyui-datagrid" 
		data-options="
		height:450,
		fitColumns:true,
		url:'ContractInfo',
		rownumbers: true,
		<!-- toolbar: '#tb', -->
		nowrap:false, 
		autoRowHeight:true,
		pagination:true,
		pageSize: 5,
		pageList:[5,10,15,20]
		">
	<thead>
		<tr>
			<th style="font-weight: 700;width: 10%" align="center" data-options="field:'contractId'">合同编号</th>
			<th style="font-weight: 700;width: 10%" align="center" data-options="field:'deptName'">部门名称</th>
			<th style="font-weight: bold;width: 10%" align="center" data-options="field:'empName'">姓名</th>
			<th style="font-weight: bold;width: 13%" align="center" data-options="field:'contractType',formatter:fornatter_type">合同类型</th>
			<th style="font-weight: bold;width: 10%" align="center" data-options="field:'contractSignedtime'">签订时间</th>
			<th style="font-weight: bold;width: 10%" align="center" data-options="field:'contractTrialtime'">试用时期</th>
			<th style="font-weight: bold;width: 10%" align="center" data-options="field:'contractDeadtime'">合同到期</th>
			<!-- <th style="font-weight: bold;width: 10%" align="center" data-options="field:''">续签</th> -->
			<th style="font-weight: bold;width: 11%" align="center" data-options="field:'contractState'">合同状态</th>
			
			
			<th field="note" style="font-weight: bold;width: 16%;" align="center" data-options="formatter:note_bianji">操作</th>
		</tr>
	</thead>
</table>
<!-- </div> -->

    </div>

</div>
<div id="ht_xgwin"></div>
</body>
</html>